package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IFinishFeedBackView;
import com.cloudsigns.factorymanager2.engineering.model.FinishFeedBackModel;
import com.cloudsigns.factorymanager2.engineering.model.IFinishFeedBackModel;

/**
 * Created by tony on 2018/4/21.
 */

public class FinishFeedBackPresenter {
    private IFinishFeedBackView view;
    private IFinishFeedBackModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public FinishFeedBackPresenter(IFinishFeedBackView view) {
        this.view = view;
        this.model = new FinishFeedBackModel();
    }

    public void submitFinishFeedBack() {


        model.submitFinishFeedBack(view.getOrderId(),view.getItemId(),view.getcompleteConten(),view.getType(),view.getcompleteCloseUpImageList(),view.getimgUrlList(),view.getOtherImgUrlList(),new  FinishFeedBackModel.OnFinishFeedBackModellListener() {
            @Override
            public void submitFinishFeedBackSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.submitFinishFeedBackSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void submitFinishFeedBackFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.submitFinishFeedBackFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
